<?php
/**
 * Prado Portal.
 *
 * @author Steen Rabol <steen.rabol@gmail.com>
 * @link http://www.pradoportal.dk/
 * @copyright Copyright &copy; 2006,2007,2008 Steen Rabol
 * @license http://www.pradoportal.dk
 * @version $Id: Login.php 394 2010-12-25 13:23:21Z steen.rabol $
 *
 */

class Login extends PortalSystemPage
{
	public function onInit($param)
	{
		parent::onInit($param);
		$this->Page->getClientScript()->registerFocusControl($this->Username);
	}

	public function validateUser($sender,$param)
	{
		$authManager=$this->Application->getModule('auth');
		if(!$authManager->login($this->Username->Text,$this->Password->Text))
		{
			$param->IsValid	= false;
		}
	}

	public function CheckUserName($sender,$param)
	{
		$username=$param->Value;

		$id = $this->DataAccess->createCommand("select * from tblusers where name='$username'")->queryRow();
		if($id)
		{
			$param->IsValid = true;
		}
		else
		{
			$param->IsValid = false;
		}
	}

	public function loginButtonClicked($sender,$param)
	{
		if($this->Page->IsValid)
		{
			$this->gotoDefaultPage();
		}
	}

	public function CancelButtonClicked($sender,$param)
	{
		$this->gotoDefaultPage();
	}
}
?>